home *** CD-ROM | disk | FTP | other *** search
/ Aminet 8 / Aminet 8 (1995)(GTI - Schatztruhe)[!][Oct 1995].iso / Aminet / dev / gcc / libnixV1_0.lha / gnu / libnix-sources.lha / examples / simplelib.c < prev   
C/C++ Source or Header  |  1995-01-22  |  4KB  |  94 lines

  1. /******************************************************************************/
  2. /*                                                                            */
  3. /* includes                                                                   */
  4. /*                                                                            */
  5. /******************************************************************************/
  6.  
  7. #include <exec/types.h>
  8. #include <exec/execbase.h>
  9. #include <dos/dosextens.h>
  10. #include <proto/exec.h>
  11. #include "stabs.h"
  12.  
  13. /******************************************************************************/
  14. /*                                                                            */
  15. /* exports                                                                    */
  16. /*                                                                            */
  17. /******************************************************************************/
  18.  
  19. const BYTE LibName[]="simple.library";
  20. const BYTE LibIdString[]="version 1.0";
  21.  
  22. const UWORD LibVersion=1;
  23. const UWORD LibRevision=0;
  24.  
  25. /******************************************************************************/
  26. /*                                                                            */
  27. /* global declarations                                                        */
  28. /*                                                                            */
  29. /******************************************************************************/
  30.  
  31. struct Library *myLibPtr;
  32. struct ExecBase *SysBase;
  33. struct DosLibrary *DOSBase;
  34.  
  35. /******************************************************************************/
  36. /*                                                                            */
  37. /* user library initialization                                                */
  38. /*                                                                            */
  39. /* !!! CAUTION: This function may run in a forbidden state !!!                */
  40. /*                                                                            */
  41. /******************************************************************************/
  42.  
  43. int __UserLibInit(struct Library *myLib)
  44. {
  45.   /* setup your library base - to access library functions over *this* basePtr! */
  46.  
  47.   myLibPtr = myLib;
  48.  
  49.   /* required !!! */
  50.   SysBase=*(struct ExecBase **)4;
  51.  
  52.   return (DOSBase=(struct DosLibrary *)OpenLibrary("dos.library",33))==NULL;
  53. }
  54.  
  55. /******************************************************************************/
  56. /*                                                                            */
  57. /* user library cleanup                                                       */
  58. /*                                                                            */
  59. /* !!! CAUTION: This function runs in a forbidden state !!!                   */
  60. /*                                                                            */
  61. /******************************************************************************/
  62.  
  63. void __UserLibCleanUp()
  64. {
  65.   CloseLibrary((struct Library *)DOSBase);
  66. }
  67.  
  68. /******************************************************************************/
  69. /*                                                                            */
  70. /* library dependent function(s)                                              */
  71. /*                                                                            */
  72. /******************************************************************************/
  73.  
  74. ADDTABL_1(__UserFunc,d0); /* One Argument in d0 */
  75.  
  76. int __UserFunc(long a)
  77. {
  78.   return a*2;
  79. }
  80.  
  81. /******************************************************************************/
  82. /*                                                                            */
  83. /* endtable marker (required!)                                                */
  84. /*                                                                            */
  85. /******************************************************************************/
  86.  
  87. ADDTABL_END();
  88.  
  89. /******************************************************************************/
  90. /*                                                                            */
  91. /* end of simplelib.c                                                         */
  92. /*                                                                            */
  93. /******************************************************************************/
  94.